/*    */ package server;
/*    */ 
/*    */ import java.io.File;
/*    */ import java.util.HashMap;
/*    */ import java.util.Map;
/*    */ import provider.MapleData;
/*    */ import provider.MapleDataProvider;
/*    */ import provider.MapleDataProviderFactory;
/*    */ import provider.MapleDataTool;
/*    */ import tools.Randomizer;
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ public class PredictCardFactory
/*    */ {
/* 22 */   private static final PredictCardFactory instance = new PredictCardFactory();
/* 23 */   protected final MapleDataProvider etcData = MapleDataProviderFactory.getDataProvider(new File(System.getProperty("wzpath") + "/Etc.wz"));
/* 24 */   protected final Map<Integer, PredictCard> predictCard = new HashMap<>();
/* 25 */   protected final Map<Integer, PredictCardComment> predictCardComment = new HashMap<>();
/*    */   
/*    */   public static PredictCardFactory getInstance() {
/* 28 */     return instance;
/*    */   }
/*    */   
/*    */   public void initialize() {
/* 32 */     if (!this.predictCard.isEmpty() || !this.predictCardComment.isEmpty()) {
/*    */       return;
/*    */     }
/* 35 */     MapleData infoData = this.etcData.getData("PredictCard.img");
/*    */     
/* 37 */     for (MapleData cardDat : infoData) {
/* 38 */       if (cardDat.getName().equals("comment")) {
/*    */         continue;
/*    */       }
/* 41 */       PredictCard card = new PredictCard();
/* 42 */       card.name = MapleDataTool.getString("name", cardDat, "");
/* 43 */       card.comment = MapleDataTool.getString("comment", cardDat, "");
/* 44 */       this.predictCard.put(Integer.valueOf(Integer.parseInt(cardDat.getName())), card);
/*    */     } 
/*    */     
/* 47 */     MapleData commentData = infoData.getChildByPath("comment");
/* 48 */     for (MapleData commentDat : commentData) {
/* 49 */       PredictCardComment comment = new PredictCardComment();
/* 50 */       comment.worldmsg0 = MapleDataTool.getString("0", commentDat, "");
/* 51 */       comment.worldmsg1 = MapleDataTool.getString("1", commentDat, "");
/* 52 */       comment.score = MapleDataTool.getIntConvert("score", commentDat, 0);
/* 53 */       comment.effectType = MapleDataTool.getIntConvert("effectType", commentDat, 0);
/* 54 */       this.predictCardComment.put(Integer.valueOf(Integer.parseInt(commentDat.getName())), comment);
/*    */     } 
/*    */   }
/*    */   
/*    */   public PredictCard getPredictCard(int id) {
/* 59 */     if (!this.predictCard.containsKey(Integer.valueOf(id))) {
/* 60 */       return null;
/*    */     }
/* 62 */     return this.predictCard.get(Integer.valueOf(id));
/*    */   }
/*    */   
/*    */   public PredictCardComment getPredictCardComment(int id) {
/* 66 */     if (!this.predictCardComment.containsKey(Integer.valueOf(id))) {
/* 67 */       return null;
/*    */     }
/* 69 */     return this.predictCardComment.get(Integer.valueOf(id));
/*    */   }
/*    */   
/*    */   public PredictCardComment RandomCardComment() {
/* 73 */     return getPredictCardComment(Randomizer.nextInt(this.predictCardComment.size()));
/*    */   }
/*    */   
/*    */   public int getCardCommentSize() {
/* 77 */     return this.predictCardComment.size();
/*    */   }
/*    */   
/*    */   public static class PredictCard {
/*    */     public String name;
/*    */     public String comment;
/*    */   }
/*    */   
/*    */   public static class PredictCardComment {
/*    */     public int score;
/*    */     public int effectType;
/*    */     public String worldmsg0;
/*    */     public String worldmsg1;
/*    */   }
/*    */ }


/* Location:              C:\PGX\Server.jar!\server\PredictCardFactory.class
 * Java compiler version: 8 (52.0)
 * JD-Core Version:       1.1.3
 */